﻿@model HmPMer.Entity.UserBaseInfo
@{
    Layout = "~/Views/Shared/_Content.cshtml";
    var gradelist = new HmPMer.Business.GradeBll().GetAllUserGrade(1);
    var wsList = new HmPMer.Business.WithdrawBll().GetAllWithdrawSchemeList(1);
}

<form class="layui-form" id="formData" style="width:90%;">
    <br />
    @Html.Hidden("UserId", Model.UserId)
    <div class="layui-row">
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">代理名称</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" lay-verify="required" id="MerName" name="MerName" value="@Model.MerName">
            </div>
        </div>

        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">代理等级</label>
            <div class="layui-input-block">
                <select name="GradeId" class="GradeId inputreadonly" lay-filter="GradeId">
                    <option value="0">请选择等级</option>
                    @foreach (var item in gradelist)
                    {
                        <option value="@item.Id" @(Model.GradeId.Equals(item.Id) ? "selected" : "")>@item.GradeName</option>
                    }
                </select>
            </div>
        </div>

        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">结算方案</label>
            <div class="layui-input-block">
                <select name="WithdrawSchemeId" class="WithdrawSchemeId" lay-filter="WithdrawSchemeId">
                    <option value="0">请选择结算方案</option>
                    @foreach (var item in wsList)
                    {
                        <option value="@item.Id" @(Model.WithdrawSchemeId.Equals(item.Id) ? "selected" : "")>@item.SchemeName</option>
                    }
                </select>
            </div>
        </div>

    </div>


    <div class="layui-row">

        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">签约类型</label>
            <div class="layui-input-block">
                <input type="radio" name="AccountType" value="0" title="个人" @(Model.AccountType == 0 ? "checked" : "")>
                <input type="radio" name="AccountType" value="1" title="企业" @(Model.AccountType == 1 ? "checked" : "")>
            </div>
        </div>

        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-block">
                <input type="password" class="layui-input" name="Pass" placeholder="" value="">
            </div>
        </div>
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">二级密码</label>
            <div class="layui-input-block">
                <input type="password" class="layui-input" name="Pass2" placeholder="" value="">
            </div>
        </div>
    </div>

    @*<div class="layui-row">
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">身份证姓名</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="FactName" placeholder="请输入身份姓名" value="@Model.FactName">
            </div>
        </div>
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">身份证号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="IdCard" placeholder="请输入身份证号" value="@Model.IdCard">
            </div>
        </div>


    </div>*@

    <div class="layui-row">
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">手机</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" id="MobilePhone" name="MobilePhone" value="@Model.MobilePhone" onkeyup="this.value=this.value.replace(/[^\d{1-9}{1}\d{0-9}]/g,'')" onafterpaste="this.value=this.value.replace(/[^\d{1-9}{1}\d{0-9}]/g,'')" placeholder="请输入手机">
            </div>
        </div>
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">Email</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="Email" value="@Model.Email" placeholder="请输入Email">
            </div>
        </div>
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">QQ</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="QQ" value="@Model.QQ" placeholder="请输入QQ号">
            </div>
        </div>
    </div>


    <div class="layui-form-item layui-row layui-col-xs12" style="text-align:center">
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-sm" id="btn_update_sub">保存</button>
        </div>
    </div>
</form>

<script type="text/javascript" src="/layui/layui.js?@ViewBag.StaticVersion"></script>
<script>

    layui.use(['hm', 'form', 'layer', 'laydate', 'table', 'laytpl'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            hm = layui.hm;


        //提交数据
        $("#btn_update_sub").click(function () {

            var MerName = $("#MerName").val();

            if (!MerName || MerName == "") {
                layer.msg("请输入代理名称！");
                return;
            }

            var MobilePhone = $("#MobilePhone").val();

            if (!MobilePhone || MobilePhone == "") {
                layer.msg("请输入手机！");
                return;
            }

            var index = layer.msg('修改中，请稍候', { icon: 16, time: false, shade: 0.8 });
            setTimeout(function () {
                layer.close(index);
                hm.ajax("/Agent/AgentUpdate", {
                    data: {
                        Model: hm.serializeObject($("#formData"))
                    },
                    type: "POST",
                    dataType: 'json',
                    success: function (result) {
                        if (result.Success) {
                            layer.msg("操作成功！", { icon: 1, time: 300, });
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.tableIns.reload();
                            parent.layer.close(index);
                        } else {
                            layer.msg(result.Message);
                        }
                    },
                    error: function (x, t, e) {
                        layer.closeAll();
                    }
                });

            }, 500);

        });

    })
</script>



